from abc import ABC, abstractmethod
from sls_controller.sls_publicResource import PublicResource
from sls_controller.sls_publicDefine import *

class Entity():
    _instance = None
    
    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
            cls._instance._initialized = False
        return cls._instance
    
    def __init__(self,public_resource:PublicResource):
        self.public_resource = public_resource
        if self.public_resource.vehicle_class == VehicleClass.UAV:
            self.id = public_resource.uav_resource.get_idStr()
        elif self.public_resource.vehicle_class == VehicleClass.UGV:
            self.id = public_resource.ugv_resource.get_idStr()
        self.entity_update_list=[]
    
    def add_entity_updates(self,*entity_update_types):
        for entity_update_type in entity_update_types:
            entity_update = entity_update_type(self)
            self.entity_update_list.append(entity_update)

class EntityUpdate(ABC):
    def __init__(self,parent_entity):
        self.parent_entity = parent_entity
        self.id = parent_entity.id
        self.public_resource:PublicResource = self.parent_entity.public_resource

    @abstractmethod
    def get_pub_topic(self) -> str:
        """
        add topic to publish
        """
        pass
        return
    @abstractmethod
    def get_dict_data(self) ->dict:
        """
        return a dict data to send
        """
        pass
        return
